import java.util.concurrent.Executor;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 86136
 * Date: 2025-04-20
 * Time: 14:10
 */
public class Demo46 {
    public static void main(String[] args) {
//        ExecutorService threadPool =  Executors.newFixedThreadPool(4);
        ExecutorService threadPool = Executors.newCachedThreadPool();
        for (int i = 0; i < 1000; i++) {
            int id = i;
            threadPool.submit(() -> {
                try {
                    Thread.sleep(1000);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
                System.out.println("hello " + id + "," + Thread.currentThread().getName());
            });
        }
    }
}
